home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / gfa / gfaexprt.lzh / GFAXPERT.LIB / FUNCTION.LST < prev    next >
Encoding:
File List  |  1986-10-19  |  1.5 KB  |  76 lines

  1. ' ********************
  2. ' *** FUNCTION.LST ***
  3. ' ********************
  4. '
  5. DEFWRD "a-z"
  6. '
  7. FUNCTION before$(source$,target$)
  8.   ' *** returns part of source$ before target$
  9.   ' *** returns complete source$ if no target$ found
  10.   LOCAL p
  11.   p=INSTR(source$,target$)
  12.   IF p=0
  13.     RETURN source$
  14.   ELSE
  15.     RETURN LEFT$(source$,p-1)
  16.   ENDIF
  17. ENDFUNC
  18. ' **********
  19. '
  20. FUNCTION after$(source$,target$)
  21.   ' *** returns part of source$ after target$
  22.   ' *** returns nullstring if no target$ found
  23.   LOCAL p
  24.   p=INSTR(source$,target$)
  25.   IF p=0
  26.     RETURN ""
  27.   ELSE
  28.     RETURN MID$(source$,p+LEN(target$))
  29.   ENDIF
  30. ENDFUNC
  31. ' **********
  32. '
  33. FUNCTION intel.word(x%)
  34.   ' *** swap low byte and high byte of word (to/from Intel-format)
  35.   RETURN CARD(ROR&(x%,8))
  36. ENDFUNC
  37. ' **********
  38. '
  39. FUNCTION digital$(number$)
  40.   ' *** return number with LCD-digits (ASCII-codes 16-25)
  41.   ' *** use as : TEXT x,y,@digital$("1237")
  42.   LOCAL dig$,i
  43.   CLR dig$
  44.   FOR i=1 TO LEN(number$)
  45.     dig$=dig$+CHR$(BCLR(ASC(MID$(number$,i,1)),5))
  46.   NEXT i
  47.   RETURN dig$
  48. ENDFUNC
  49. ' **********
  50. '
  51. FUNCTION multiple(n%,fac)
  52.   ' *** returns smallest multiple of fac ≥ n% (n%>0)
  53.   LOCAL m
  54.   m=MOD(n%,fac)
  55.   IF m>0
  56.     RETURN n%+fac-m
  57.   ELSE
  58.     RETURN n%
  59.   ENDIF
  60. ENDFUNC
  61. ' **********
  62. '
  63. FUNCTION lower$(t$)
  64.   ' *** converts all upper case letters in t$ to lower case
  65.   LOCAL i,a%,c|
  66.   adr%=V:t$
  67.   FOR i=0 TO PRED(LEN(t$))
  68.     a%=ADD(adr%,i)
  69.     c|=BYTE{a%}
  70.     IF c|>=65 AND c|<=90
  71.       BYTE{a%}=BSET(c|,5)
  72.     ENDIF
  73.   NEXT i
  74.   RETURN t$
  75. ENDFUNC
  76.